package cn.besbing.server.service.primary;

import cn.besbing.model.entities.primary.DlActionTable;
import cn.besbing.model.entities.primary.EngineerManage;
import cn.besbing.model.mapper.primary.EngineerManageMapper;
import cn.besbing.model.utils.SearchDTO;
import com.github.pagehelper.PageHelper;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class PrimaryEngineerImpl {

    @Autowired(required = false)
    EngineerManageMapper engineerManageMapper;
    public List<EngineerManage> getDataForTable(SearchDTO searchDTO){

        String name = SecurityUtils.getSubject().getPrincipal().toString();
        List<EngineerManage> list = new ArrayList<EngineerManage>();
        PageHelper.startPage(searchDTO.getPage(), searchDTO.getLimit(),true);
        if(searchDTO.getKeyword() != null){
            list = engineerManageMapper.selectAction(searchDTO.getKeyword().toString(),name);
        }else {
            list = engineerManageMapper.selectAction(null,name);
            //list = permissionMapper.selectByExample(null);
        }
        return list;
    }

}
